﻿using Newtonsoft.Json;

namespace Hpt.Device.Sample.Dto;

public class DeviceResponseBaseV1
{
    [JsonProperty(NullValueHandling = NullValueHandling.Include, PropertyName = "Msg", Order = 1)]
    public string Msg { get; set; } = string.Empty;

    [JsonProperty(NullValueHandling = NullValueHandling.Include, Order = 0)]
    public string Status => Code.ToString();

    [JsonIgnore]
    public int Code { get; set; } = 100;

    public static DeviceResponseBaseV1 Error(DeviceErrorResponse error)
    {
        return new DeviceResponseBaseV1
        {
            Code = error.Code,
            Msg = error.Msg
        };
    }

    public static readonly DeviceResponseBaseV1 Success = new DeviceResponseBaseV1();
}